package com.shimao.celnet.payment.model.request;

import com.shimao.celnet.payment.util.FinalUtil;
import com.shimao.celnet.payment.util.SignCheckUtil;
import org.apache.log4j.Logger;

import java.util.TreeMap;

/**
 * 接口Header抽象类
 * Created by ensure.xu on 2017/12/9.
 */
public  class Header {

    protected Logger logger = Logger.getLogger(this.getClass());
    /**
     *请求数据类型
     */
    private String ContentType= FinalUtil.CONTENT_TYPE;

    /**
     *方法名称
     */
    private String method;

    /**
     *应用ID，应用系统ID,例如：101：物业计费系统
     */
    private String appKey;

    /**
     *接口ID
     */
    private String integrationId;

    /**
     *时间戳
     */
    private String timestamp;

    /**
     *签名
     */
    private String sign;

    /**
     *时间戳有效时间：毫秒
     */
    private String validTime;

    /**
     * token
     */
    private String token;

    public Boolean CheckSign() throws Exception {
        TreeMap<String, String> headers = new TreeMap<String, String>();
        headers.put(FinalUtil.HEADER_CONTENT_TYPE,this.getContentType());
        headers.put(FinalUtil.HEADER_METHOD,this.getMethod());
        headers.put(FinalUtil.HEADER_APP_KEY,this.getAppKey());
        headers.put(FinalUtil.HEADER_TIMESTAMP,this.getTimestamp());
        headers.put(FinalUtil.HEADER_INTERFACE_ID,this.getIntegrationId());
        headers.put(FinalUtil.HEADER_SIGN,this.getSign());
        return SignCheckUtil.checkMySign(headers,this.token);
    }

    public String getContentType() {
        return ContentType;
    }

    public void setContentType(String contentType) {
        ContentType = contentType;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getAppKey() {
        return appKey;
    }

    public void setAppKey(String appKey) {
        this.appKey = appKey;
    }

    public String getIntegrationId() {
        return integrationId;
    }

    public void setIntegrationId(String integrationId) {
        this.integrationId = integrationId;
    }

    public String getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getValidTime() {
        return validTime;
    }

    public void setValidTime(String validTime) {
        this.validTime = validTime;
    }

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }
}
